package com.jaylli.ai.services;


import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * MCP Server： MCP服务端
 */
@Service
public class McpServerDateService {

    @Tool(name = "获取当前时间", description = "Get the current date and time in the user's timezone")
    public String getCurrentDateTime(@ToolParam(description = "记录个日志") String log) {
        return LocalDateTime.now().atZone(LocaleContextHolder.getTimeZone().toZoneId()).toString();
    }

    @Tool(name = "设置闹钟", description = "Set a user alarm for the given time, provided in ISO-8601 format")
    public String setAlarm(@ToolParam(description = "闹钟的时间，是一个字符串") String time) {
        LocalDateTime alarmTime = LocalDateTime.parse(time, DateTimeFormatter.ISO_DATE_TIME);
        return "Alarm set for " + alarmTime;
    }
}
